package com.project.service.impl;

import com.project.mapper.PublicMapper;
import com.project.pojo.*;
import com.project.service.PublicService;
import com.project.utils.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PublicServiceImpl implements PublicService {

    @Autowired
    private PublicMapper publicMapper;
    /**
     * 查询所有公告
     *
     * @return
     */
    @Override
    public List<Notice> selectAllNotice() {
        //调用方法
        return publicMapper.selectAllNotice();
    }

    /**
     * 查询所有教学楼
     *
     * @return
     */
    @Override
    public List<Build> selectAllBuild() {
        //调用方法
        return publicMapper.selectAllBuild();
    }

    /**
     * 查询所有教室
     */
    @Override
    public List<Room> selectAllRoom() {
        //调用方法
        return publicMapper.selectAllRoom();
    }

    /**
     * 查询所有 申请
     * @return
     */
    @Override
    public List<Apply> selectAllApply() {
        //调用方法
        List<Apply> applyList = publicMapper.selectAllApply();
        return applyList;
    }

    /**
     * 审批申请
     */
    @Override
    public void updateApply(Apply apply) {
        //调用方法
        publicMapper.updateApply(apply);
    }

    /**
     * 根据信息查询教学楼
     * @param buildName
     * @return
     */
    @Override
    public List<Build> selectBuildByInfo(String buildName) {
        List<Build> buildList = publicMapper.selectBuildByInfo(buildName);
        return buildList;
    }

    /**
     * 根据教学楼名称查询教室
     * @param buildName
     * @return
     */
    @Override
    public List<Room> selectRoomByInfo(String buildName) {
        List<Room> roomList = publicMapper.selectRoomByInfo(buildName);
        return roomList;
    }

    /**
     * 根据申请人姓名模糊查询申请
     * @param relName
     * @return
     */
    @Override
    public List<Apply> selectApplyByInfo(String relName) {
        List<Apply> applyList = publicMapper.selectApplyByInfo(relName);
        return applyList;
    }

    /**
     * 模糊查询管理员
     * @param relName
     * @return
     */
    @Override
    public List<Admin> selectAdminByInfo(String relName) {
        List<Admin> adminList = publicMapper.selectAdminByInfo(relName);
        return adminList;
    }

    /**
     * 模糊查询教职工
     * @param tName
     * @return
     */
    @Override
    public List<Teacher> selectTeacherByInfo(String tName) {
        List<Teacher> teacherList = publicMapper.selectTeacherByInfo(tName);
        return teacherList;
    }

    /**
     * 模糊查询学生
     * @param relName
     * @return
     */
    @Override
    public List<User> selectUserByInfo(String relName) {
        List<User> userList = publicMapper.selectUserByInfo(relName);
        return userList;
    }
}
